package com.sgcc.fj.pmos.e_fj_personalcenter.activity;

import android.view.View;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.flyco.tablayout.SlidingTabLayout;
import com.sgcc.fj.pmos.arouter.personalcenter.PersonalCenterArouterPath;
import com.sgcc.fj.pmos.common.adapter.HomeTabPagerAdapter;
import com.sgcc.fj.pmos.common.base.BaseActivity;
import com.sgcc.ln.pmos.common.widget.TitleBar;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.fj.pmos.e_fj_personalcenter.fragment.DeviationCurveFragment;
import com.sgcc.fj.pmos.e_fj_personalcenter.fragment.PowerCurveFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * 自定义曲线管理
 */
@Route(path = PersonalCenterArouterPath.PERSONALCENTER_CUSTOMCURVEMANAGEMENT)
public class CustomCurveManagementActivity extends BaseActivity {

    private TitleBar mTitleBar;
    private SlidingTabLayout mStlContent;
    private ViewPager mViewpager;
    private List<Fragment> fragments = new ArrayList<>();
    private HomeTabPagerAdapter homeTabPagerAdapter;

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_customcurvemanagement;
    }

    @Override
    protected void initViews() {
        super.initViews();
        mTitleBar = (TitleBar) findViewById(R.id.title_bar);
        mStlContent = (SlidingTabLayout) findViewById(R.id.stl_content);
        mViewpager = (ViewPager) findViewById(R.id.viewpager);

        mTitleBar.setTitle("自定义曲线管理");
        mTitleBar.setRightIcon(R.mipmap.go_main, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                goMainActivity();
            }
        });

        String[] titleList = getResources().getStringArray(R.array.personalcenter_curve);

        PowerCurveFragment powerCurveFragment = new PowerCurveFragment();
        DeviationCurveFragment deviationCurveFragment = new DeviationCurveFragment();

        fragments.add(powerCurveFragment);
        fragments.add(deviationCurveFragment);
        homeTabPagerAdapter = new HomeTabPagerAdapter(getSupportFragmentManager(), fragments);
        homeTabPagerAdapter.setmBottomTabNames(titleList);
        mViewpager.setOffscreenPageLimit(2);
        mViewpager.setAdapter(homeTabPagerAdapter);
        mStlContent.setViewPager(mViewpager);

    }
}
